<?php

namespace app\admin\model\dymz;

use think\Model;


class Script extends Model
{

    

    

    // 表名
    protected $name = 'dymz_script';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'serial_status_text',
        'tag_list_text',
        'qualification_text'
    ];
    
    
    
    public function getSerialStatusList()
    {
        return ['1' => __('Serial_status 1'), '2' => __('Serial_status 2'), '3' => __('Serial_status 3')];
    }

    
    public function getOperateStatusList()
    {
        return ['1' => '审核版本上线', '2' => '线上版本上架', '3' => '线上版本下架'];
    }

    public function getTagListList()
    {
        return ['1' => __('Tag_list 1'), '2' => __('Tag_list 2'), '3' => __('Tag_list 3'), '4' => __('Tag_list 4'), '5' => __('Tag_list 5'), '6' => __('Tag_list 6'), '7' => __('Tag_list 7'), '8' => __('Tag_list 8'), '9' => __('Tag_list 9'), '10' => __('Tag_list 10'), '11' => __('Tag_list 11'), '12' => __('Tag_list 12'), '13' => __('Tag_list 13'), '14' => __('Tag_list 14'), '15' => __('Tag_list 15'), '16' => __('Tag_list 16'), '17' => __('Tag_list 17'), '18' => __('Tag_list 18'), '19' => __('Tag_list 19'), '20' => __('Tag_list 20'), '21' => __('Tag_list 21'), '22' => __('Tag_list 22'), '23' => __('Tag_list 23'), '24' => __('Tag_list 24'), '25' => __('Tag_list 25'), '26' => __('Tag_list 26'), '27' => __('Tag_list 27'), '28' => __('Tag_list 28'), '29' => __('Tag_list 29'), '30' => __('Tag_list 30'), '31' => __('Tag_list 31'), '33' => __('Tag_list 33'), '34' => __('Tag_list 34'), '35' => __('Tag_list 35'), '36' => __('Tag_list 36'), '37' => __('Tag_list 37'), '38' => __('Tag_list 38'), '39' => __('Tag_list 39'), '40' => __('Tag_list 40'), '41' => __('Tag_list 41'), '42' => __('Tag_list 42'), '43' => __('Tag_list 43'), '44' => __('Tag_list 44'), '45' => __('Tag_list 45'), '46' => __('Tag_list 46')];
    }

    public function getQualificationList()
    {
        return ['1' => __('Qualification 1'), '2' => __('Qualification 2'), '3' => __('Qualification 3'), '4' => __('Qualification 4')];
    }


    public function getSerialStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['serial_status']) ? $data['serial_status'] : '');
        $list = $this->getSerialStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTagListTextAttr($value, $data)
    {
        $value = $value ?: ($data['tag_list'] ?? '');
        $valueArr = explode(',', $value);
        $list = $this->getTagListList();
        return implode(',', array_intersect_key($list, array_flip($valueArr)));
    }


    public function getQualificationTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['qualification']) ? $data['qualification'] : '');
        $list = $this->getQualificationList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    protected function setTagListAttr($value)
    {
        return is_array($value) ? implode(',', $value) : $value;
    }


}
